
using System.IO;
using System.Reflection;
using System.Xml.Serialization;
using System.Collections.Generic;
using System;
using Lizk.Utilities;
using Lizk.SimpleHUD;

namespace SharpMedia
{
    [XmlRoot]
    public class Settings
    {
        public SizeS WindowSize = new SizeS(1280, 720);
        public WindowMode WindowedMode = WindowMode.Windowed;
        public bool UseExclusiveFullscreen { get; set; }

        public string MountDrive { get; set; }
        public string MountProgramArguments { get; set; }
        public string MountProgramPath { get; set; }


        public List<MediaCategory> MediaCategories { get; set; }
        public List<QuickLink> QuickLinks { get; set; }


        public Settings()
        {
        }
        public void InitDefaultValues()
        {
            UseExclusiveFullscreen = true;
            MountProgramPath = @"C:\Program Files\DAEMON Tools\daemon.exe";
            MountProgramArguments = "-mount 0,\"{0}\"";
            MountDrive = "F:";

            MediaCategories = new List<MediaCategory>();
            MediaCategories.Add(new MediaCategory("tvshows", "TV-Shows", "TVScrapers.TVDBScraper", typeof(MediaData.TVScanner).AssemblyQualifiedName));
            MediaCategories.Add(new MediaCategory("movies", "Movies", "MovieScrapers.ImdbScraper", typeof(MediaData.MovieScanner).AssemblyQualifiedName));
            MediaCategories.Add(new MediaCategory("anime", "Anime", "AnimeScrapers.AnimeDBScraper", typeof(MediaData.AnimeScanner).AssemblyQualifiedName));

            QuickLinks = new List<QuickLink>();
            QuickLinks.Add(new QuickLink(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), "Desktop", "User desktop", "folder.png"));
        }

        public static bool TryLoadSettings(string file, out Settings settings)
        {
            if (File.Exists(file))
            {
                try
                {
                    settings = XmlSettings.loadXml<Settings>(file);
                    return true;
                }
                catch
                {
                }
            }
            settings = new Settings(); settings.InitDefaultValues();
            return false;
        }

    }
}
